﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RestSharp;

namespace Openapi.Weibo
{
    public static class ParameterExtensions
    {
        public static Parameter[] ToParameterArry(this IDictionary<string, object> @params)
        {
            return @params.Select(p => new Parameter 
            { 
                Name=p.Key,
                Value=p.Value,
                Type=ParameterType.GetOrPost
            }).ToArray();
        }

        public static void AddRangeParameter(this IRestRequest request,IEnumerable<Parameter> @params)
        {
            if(request==null)
                throw new NullReferenceException();
            foreach (var p in @params)
            {
                request.AddParameter(p);
            }
        }
    }
}
